#pragma once

#include <engine.core/Reflection.hpp>




namespace Engine
{
	namespace Video
	{
		/**
		 * This class describes one constant buffer in a shader.
		 * It stores D3D's specific reflection data in the reflection format,
		 * used by this engine.
		 */
		class D3D11ShaderConstant
		{
		public:

			/**
			 * Create a D3D11ShaderConstant from the given reflection-constant buffer and buffer description.
			 */
			D3D11ShaderConstant(ID3D11ShaderReflectionConstantBuffer* buffer, const D3D11_SHADER_BUFFER_DESC& desc, uint32 index);



			/**
			 * Compares the stored Reflection (from the shader) against the given one
			 * and then stores the static reflection, so that further comparisons only
			 * involve a shallow compare.
			 */
			void compare(const StaticReflection& reflection);

			/**
			 * Get the index under which this 
			 */
			uint32 index() const;



			/**
			 * Get the format type that describes the given shader variable class.
			 * Throws an exception when there is no appropriate format.
			 */
			static Format::Type fromClass(D3D10_SHADER_VARIABLE_CLASS c);

		private:

			uint32                              m_index;
			Reflection                          m_reflection;
			boost::optional<StaticReflection>   m_staticReflection;
		};
		///////////////////////////////////////////////////////////////////////////////////////////
	}
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
